#!/usr/bin/env python
# -*-coding: utf-8-*-
# AUTHOR ：Arthur
# DATE   ：2016-10-21
# INTRO  ：
# VERSION：0.1

import subprocess
import config
import re

proxies = []
with open(config.PEER_FILE) as f:
    s = f.read().strip()
    peers = s.split("\n")
    for peer in peers:
        ipdate = re.findall('cache_peer (.*?)  parent (.*?) 0 proxy-only round-robin',peer,re.S)[0]
        ip = ipdate[0]
        port = ipdate[1]
        ipport = ip + ":" + port
        proxies.append(ipport)
print(proxies)